Specifying a Label for a Control

The <label> tag in HTML specifies a label for a control. It defines a set of text that is associated with a particular element. If you use the <label> tag the users can select the radio button or the check box control by clicking on its label. The <label> tag describes the control with which it is associated.

Let’s do the following steps to specify a label for a control:


<!DOCTYP html>
<html>
<head>
<title>Specifying a Label for a Control</title>
</head>
<body>
<center>
    <h3>Example of Using label element</h3>
    <fieldset>
    <legend><b>Personal Information:</b></legend><br>
    <label for =”fname”>First Name:</label>
 <input type=”text” name=”firstname” id=”fname” size=”30” />
    <label for=”lname”>Last Name:</label>    
    <input type=”text” name=”fristname” id=”laname” size=”30”/>
    <label for=”male”>Male:</label>
    <input type=”radio” name=”sex” id=”male” size=”30”/>
    <label for=”female”>Female:</label>
    <input type=”radio” name=”sex” id=”female” size=”30”/>
    </fieldset>
</center>
</body>
</html>

Save the document with the name LabelControl.html and open on browser.